import random


def guess_number_game():
    number_to_guess = random.randint(1, 10)
    guess = None
    attempts = 0

    while guess != number_to_guess:
        guess = int(input("猜一个1到10之间的数字: "))
        attempts += 1

        if guess < number_to_guess:
            print("太小了！再试一次。")
        elif guess > number_to_guess:
            print("太大了！再试一次。")

    print(f"恭喜你！你猜对了数字{number_to_guess}。你总共尝试了{attempts}次。")


guess_number_game()